home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C & C++ Multimedia Cyber Classroom
/
C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso
/
src
/
fig09_05.jar
/
Ch09
/
Fig09_05
/
Hourly.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1997-10-27
|
954b
|
31 lines
// Fig. 9.5: hourly.cpp
// Member function definitions for class HourlyWorker
#include <iostream.h>
#include <iomanip.h>
#include "hourly.h"
// Constructor for class HourlyWorker
HourlyWorker::HourlyWorker( const char *first,
const char *last,
double initHours, double initWage )
: Employee( first, last ) // call base-class constructor
{
hours = initHours; // should validate
wage = initWage; // should validate
}
// Get the HourlyWorker's pay
double HourlyWorker::getPay() const { return wage * hours; }
// Print the HourlyWorker's name and pay
void HourlyWorker::print() const
{
cout << "HourlyWorker::print() is executing\n\n";
Employee::print(); // call base-class print function
cout << " is an hourly worker with pay of $"
<< setiosflags( ios::fixed | ios::showpoint )
<< setprecision( 2 ) << getPay() << endl;
}